package zoo.reviewboard.user.controller;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import zoo.member.admin.util.StringUtil;
import zoo.reviewboard.user.dao.ProductReviewBoardDao;
import zoo.reviewboard.user.domain.ProductReviewBoardCommand;
import zoo.reviewboard.user.validator.ProReviewValidator;

@Controller
public class ProductReviewBoardDetailController {	
	
	private static Log log = LogFactory.getLog(ProductReviewBoardDetailController.class);
	
	@Autowired
	private ProductReviewBoardDao reviewDao;
	
	@RequestMapping("/main/reviewDetail.do")
	public ModelAndView process(@RequestParam("pr_num")int pr_num,ProductReviewBoardCommand command,BindingResult result){
		
		new ProReviewValidator().validate(command, result);
		
		if(log.isDebugEnabled()){
			log.debug("pr_num : " + pr_num);
		}
				
		ProductReviewBoardCommand member = reviewDao.selectReview(pr_num);
		
		reviewDao.updateReviewHit(pr_num);

		//주소 줄바꿈 처리
		member.setPr_content((StringUtil.parseBr(member.getPr_content())));
		
		return new ModelAndView("review_detail","member",member);
	}
}
